//
//  RepairHistoryProcessCell.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14/11/14.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "RepairHistoryProcessCell.h"

@implementation RepairHistoryProcessCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    _titleLabel = [self createLabelWithFrame:CGRectMake(5, 15, 80, 20) text:@"" font:18 textAli:NSTextAlignmentCenter textColor:MAIN_BLUE_COLOR];
    [self.contentView addSubview:_titleLabel];
    
    _curTimeLabel = [self createLabelWithFrame:CGRectMake(_titleLabel.right+5, 10, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_curTimeLabel];
    
    _remarkLabel = [self createLabelWithFrame:CGRectMake(_titleLabel.right+5, 10, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_remarkLabel];
    
    _timeLabel = [self createLabelWithFrame:CGRectMake(_remarkLabel.left, _remarkLabel.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_timeLabel];
    
    _processorLabe = [self createLabelWithFrame:CGRectMake(_timeLabel.left, _timeLabel.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_processorLabe];
    
    _phoneLabel = [self createLabelWithFrame:CGRectMake(_processorLabe.left, _processorLabe.bottom+3, 200, 20) text:@"" font:14 textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self.contentView addSubview:_phoneLabel];
    
}


//steps =     (
//             {
//                 acceptanceTime = "2015-01-10 13:54:32";
//                 message = "\U7cfb\U7edf\U5df2\U53d7\U7406\U4f60\U7684\U62a5\U4fee";
//                 progressState = 1;
//             },
//             {
//                 acceptanceTime = "2015-01-10 13:55:18";
//                 message = 18989898989;
//                 personnsName = "\U5468\U597d\U5448";
//                 personnsPhone = 18989898989;
//                 progressState = 2;
//             },
//             {
//                 acceptanceTime = "2015-01-10 13:55:55";
//                 message = "\U5468\U597d\U4e8b";
//                 personnsName = "\U5468\U597d\U4e8b";
//                 personnsPhone = 18989898989;
//                 progressState = 3;
//             }
//             );

-(void)setSteps:(RepairDetailModel *)steps{
    
    if(_steps != steps){
        _steps = steps;
        
        NSString* status = steps.progressState;
        
        switch (status.intValue) {
            case 1:
            {
                _titleLabel.text = @"待受理";
                _curTimeLabel.text = steps.acceptanceTime;
                _remarkLabel.text = steps.message;
                //_timeLabel.text = steps.acceptanceTime;
                _remarkLabel.top = _curTimeLabel.bottom+10;
                //_timeLabel.top = _timeLabel.bottom+3;
            }
                break;
            case 2:{
                _titleLabel.text = @"处理中";
                _curTimeLabel.alpha = 0;
                _processorLabe.text =[NSString stringWithFormat:@"手机号:%@",steps.personnsPhone];
                _phoneLabel.text = [NSString stringWithFormat:@"留言:%@",steps.message];
                _timeLabel.text =[NSString stringWithFormat:@"处理人:%@",steps.personnsName];
                _remarkLabel.text =steps.acceptanceTime;;
            }
                 break;
            case 3:
            {
                _titleLabel.text = @"处理完成";
                
                _curTimeLabel.alpha = 0;
                _processorLabe.text =[NSString stringWithFormat:@"手机号:%@",steps.personnsPhone];
                _phoneLabel.text = [NSString stringWithFormat:@"留言:%@",steps.message];
                _timeLabel.text =[NSString stringWithFormat:@"处理人:%@",steps.personnsName];
                _remarkLabel.text =steps.acceptanceTime;;
                
            }break;
            default:
                break;
        }

    }
    
}

-(UILabel*)createLabelWithFrame:(CGRect)frame text:(NSString*)text font:(int)font textAli:(NSTextAlignment)alig textColor:(UIColor*)tc{
    if(text == nil)
    text = @"";
    UILabel* label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = alig;
    label.textColor = tc;
    label.backgroundColor = [UIColor clearColor];
    return label;
}

@end
